import request from '@/util/request'

const purchaseUrl = '/warehouse/purchase/'

export function addPurchaseDetail(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'add/purchaseDetail',
        data,
    })
}

export function getPurchaseDetailPageList(searchDto) {
    return request({
        method: 'get',
        url: purchaseUrl + 'get/purchaseDetail/list/condition/',
        params: searchDto
    })
}

export function addPurchase(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'add/purchase',
        data,
    })
}

export function getPurchasePageList(searchDto) {
    return request({
        method: 'get',
        url: purchaseUrl + 'get/purchase/list/condition/',
        params: searchDto
    })
}
/*获取当前登录人（已领取）的采购单*/
export function getMyPurchaseList() {
    return request({
        method: 'get',
        url: purchaseUrl + 'get/my/purchase/list',
    })
}


export function getPurchaseUnreceiveList() {
    return request({
        method: 'get',
        url: purchaseUrl + 'get/purchase/unreceive/list',
    })
}
export function getPurchaseDetailListByPurchaseId(purchaseId) {
    return request({
        method: 'get',
        url: purchaseUrl + 'get/purchaseDetail/list/by/purchaseId',
        params:{
            purchaseId
        }
    })
}
export function mergePurchaseDetail(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'merge/purchaseDetail',
        data,
    })
}
export function finishPurchase(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'finish/purchase',
        data,
    })
}

export function PurchaseAssignment(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'assignment/purchase',
        data,
    })
}

export function receivePurchase(data) {
    return request({
        method: 'post',
        url: purchaseUrl + 'receive/purchase',
        data,
    })
}
export function modifyPurchase(data) {
    return request({
        method: 'put',
        url: purchaseUrl + 'modify/purchase',
        data,
    })
}
export function getPurchaseById(purchaseId){
    return request({
        method: 'get',
        url: purchaseUrl + "purchaseId",
        params:{
            purchaseId
        }
    })
}
export function exportPurchase(){
    return request({
        method: 'get',
        url: purchaseUrl + "export",
        responseType: 'arraybuffer'
    })
}
